<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
    import="java.sql.*"
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert Annonce</title>
</head>
<body>
<%
Connection conn=null;
Statement stmt=null;
try{
	Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e){
	System.out.print("la classe est introuvale");
	e.printStackTrace();
	}
try{
	String url="jdbc:mysql://localhost:3306/base_labrocante";
	String user="root";
	String pw="";
	int iduser=Integer.parseInt(""+session.getAttribute("iduser"));
	String nom=(String)session.getAttribute("nomuser");
	String titre=request.getParameter("titre");
	String texteAnnonce=request.getParameter("texteAnnonce");
	int tel=Integer.parseInt(request.getParameter("tel"));
	float prix = Float.parseFloat(request.getParameter("prix"));
	String ville=request.getParameter("ville");
	String categorie=request.getParameter("categorie");
	conn=DriverManager.getConnection(url,user,pw);
	stmt = conn.createStatement();
	out.print(nom);
	String req1="insert into annonce (idUtilisateur,titre,texteAnnonce,tel,prix,ville,categorie,utilisateur,valider) values ("+iduser+",'"+titre+"','"+texteAnnonce+"',"+tel+","+prix+",'"+ville+"','"+categorie+"','"+nom+"',0)";	
	stmt.executeUpdate(req1);
	response.sendRedirect("allAnnonce.jsp");
	%>

<%
}
catch(SQLException e){
e.printStackTrace();
}
%>
Ajout Annonce valide
</body>
</html>